import { createSlice } from '@reduxjs/toolkit'

/**
 * @description  2024-01-05 zyj 添加,因为request.headers 添加AuthToken参数
 */
export const loginAuthTokenSlice = createSlice({
  name: 'loginAuthToken',
  initialState: () => {
    const baseAuthToken = localStorage.getItem('baseAuthToken')
    return baseAuthToken || ''
  },
  reducers: {
    updateLoginAuthToken: (
      state,
      { payload = '' }: { payload: string | undefined }
    ) => {
      localStorage.setItem('baseAuthToken', payload)
      return payload
    }
  }
})
